Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
PushState requires two "go back" but then "go forward" will stop working

I have a very rudimentary SPA built in vanilla JS. There are two buttons that the user can use to navigate between pages, for example:

buttonProfile.addEventListener("click", function () {
  window.history.pushState({}, "", "profile/");
  var updatePage = new Event("update-page");
  dispatchEvent(updatePage);
});

Somewhere in the app, I have an event listener that listens to update-page to refresh the content that needs to be refreshed (without ever reloading the page) based on the current URL. Everything works fine.

However, I noted two odd behaviours:

  • If the user starts on Page A and then moves to Page B, the user will need to go back twice (button on the browser) in order to go back to Page A.
  • If the user goes back from Page B to Page A, once they are back to Page A the "forward" button on the browser will become greyed out.

EDIT

In case it helps, I noted I have the same issue when I use other people's SPAs that have a similar implementation. See this simple demo for example: DEMO | CODE

Steps to reproduce:

  • Click on About, then Contact, then again About, then again Contact.
  • Now, if you press Back once you'll go back to About. However, if you press it again you'll stay on About. You'll have to press it again to move to Contact and once you do, the Forward button will be disabled.

EDIT 2

I just realize that both my site and the site I posted above work fine when I run my browser in Incognito. There must be some other problem with my Chrome (though I have no idea what).

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Okay, I found it. It was the Matter official Chrome extension. Not sure what exactly caused the issue though.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!